package com.portomx.agenda.dao.impl;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.portomx.agenda.commons.AppException;
import com.portomx.agenda.dao.DireccionDao;
import com.portomx.agenda.model.Direccion;

@Repository
public class DireccionDaoImpl implements DireccionDao {

	@Autowired
	private SessionFactory sessionFactory;

	@Transactional
	@Override
	public void create(Direccion direccion) {
		try {
			Assert.notNull(direccion);
			sessionFactory.getCurrentSession().save(direccion);
		} catch (Exception ex) {
			throw new AppException("Error al guardar los datos", ex);
		}
	}

}
